package harima.collision.bodies;

public class PlatformPath {
	
	
	PathNode currentNode;
	PathNode firstNode;
	PathNode lastNode;
	
	public void addNode(PathNode node)
	{
		if(firstNode == null)
		{
			firstNode = node;
			lastNode = node;
			currentNode  = node;
		}
		else
		{
			lastNode.nextNode = node;
			lastNode = node;
		}
	}
	
	public PathNode getFirstNode(){return firstNode;}
	
	public boolean step()
	{
		boolean endStep = true;
		
		if(currentNode != null)
		{
			currentNode.step();
			endStep = currentNode.reachedEnd();
		}
		
		return endStep;
	}
	
	public PathNode nextNode()
	{
		PathNode nextNode = null;
		
		if(currentNode != null)
		{
			nextNode = currentNode.nextNode;
			currentNode = currentNode.nextNode;
		}
		if(nextNode == null)
		{
			nextNode = firstNode;
			currentNode = firstNode;
		}
		
		return nextNode;
	}
	
}
